package main

import (
	"bubble/dao"
	"bubble/models"
	"bubble/routers"
	"bubble/setting"
	"fmt"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

var err error

func main() {
	err = setting.Init("conf/config.ini")
	if err != nil {
		panic("配置文件不存在")
	}
	err = dao.InitMySQL(setting.Conf.MySQLConfig)
	dao.DB.AutoMigrate(&models.Todo{})
	if err != nil {
		panic(fmt.Errorf("数据库加载失败 %v", err))
	}
	r := routers.SetupRouter()
	r.Run(":8080")
}
